﻿using AdminSystem.Application;
using AdminSystem.WebApi.DTOs;
using AdminSystem.WebApi.MedialRs.Commands.UserLogin;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AdminSystem.WebApi.Controllers
{
    /// <summary>
    /// 用户控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        public UserController(IMediator mediator)
        {
            Mediator = mediator;
        }

        public IMediator Mediator { get; }


        /// <summary>
        /// 中介者登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="userPass"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<UserDto>>> UserLogin(string? userName, string? userPass)
        {
            UserLoginCommand command = new UserLoginCommand
            {
                UserName = userName,
                Password = userPass
            };
            return await Mediator.Send(command);
        }
    }
}
